package com.lanhao.aot.excel;

import java.util.ArrayList;
import java.util.List;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;

public class DeviceDataProcess {
	public static final String totalDataExcel = "D://totalDataExcel.xlsx";
	public static final String checkDataPath = "D://checkData.txt";
	
	public static void main(String[] args) {
		
		List<String> checkDataList = FileUtil.readLines(checkDataPath, "UTF-8");
		
		List<List<String>> rows = new ArrayList<List<String>>();
		ExcelReader reader = ExcelUtil.getReader(totalDataExcel, 0);
		List<List<Object>> allDataList = reader.read();
		for (int i = 2; i < allDataList.size(); i++) {
			List<Object> list = allDataList.get(i);
			System.out.println(list.get(3));
			String imei = ((Long) list.get(3)).toString().trim();
			List<String> row = null;
			if(checkDataList.contains(imei)) {
				row = CollUtil.newArrayList(imei, "是");
			} else {
				row = CollUtil.newArrayList(imei, "否");
			}
			rows.add(row);
		}
		
		
		//通过工具类创建writer
		ExcelWriter writer = ExcelUtil.getWriter("D:/resultExcel.xlsx");

		//跳过当前行，既第一行，非必须，在此演示用
		writer.passCurrentRow();

		//合并单元格后的标题行，使用默认标题样式
//		writer.merge(row1.size() - 1, "测试标题");
		//一次性写出内容，强制输出标题
		writer.write(rows, true);
		//关闭writer，释放内存
		writer.close();
		
		
	}
}
